package com.tiniplanet.webgate.dao.hibernate;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.tiniplanet.webgate.dao.CredentialDao;
import com.tiniplanet.webgate.entity.Credential;

@Transactional
public class CredentialDaoImpl extends BaseDaoImpl<Credential, Long> implements CredentialDao {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4974799943474939721L;

	public CredentialDaoImpl(Class<Credential> type) {
		super(type);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Credential getByUsername(String username) {
		List<Credential> result = getHibernateTemplate().find(
				"from Credential as credential where username=?", username);
		if (result.size() > 0)
			return result.get(0);
		else
			return null;
	}

}
